package com.atguigu.controller;

import com.atguigu.domain.User;
import com.atguigu.service.UserService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@ResponseBody
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;

    @RequestMapping("/find/{id}")
    public User findById(@PathVariable("id") Integer id) throws InterruptedException {
//        if (id==2) {
//            System.out.println("time out");
//            Thread.sleep(3000);
//        }
        User user = userService.findById(id);
        user.setUsername("user-provider-demo1");
        return user;
    }

}
